//
// Created by benxb on 2021/11/16.
//

#ifndef BENXDB_DATA_CHUNK_DELETE_BITMAP_H
#define BENXDB_DATA_CHUNK_DELETE_BITMAP_H

#include <string>
#include <fstream>
#include <vector>

namespace benxdb {

class DataChunkDeleteBitmap {
public:
    explicit DataChunkDeleteBitmap(const std::string&  table_name);
    ~DataChunkDeleteBitmap();

    bool DeleteRecord(uint64_t record_id);

    bool DeleteBatch(const std::vector<uint64_t>& record_ids);

    /**
     * Check if record is delete
     * @param record_id id of record
     * @return
     */
    bool IsDelete(uint64_t record_id);

    void AppendChunk(uint64_t record_count);

    /**
     * Expand delete_map file with the chunk
     */
    void AppendChunk();

    /**
     * Get table name
     * @return table name
     */
    std::string TableName() {
        return table_name_;
    }

    /**
     * Get bitmap file name
     * @return bitmap file
     */
    std::string BitmapFile() {
        return bitmap_file_;
    }

private:
    std::string table_name_;
    std::string bitmap_file_;
    std::fstream db_io_;
};

}

#endif //BENXDB_DATA_CHUNK_DELETE_BITMAP_H
